<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>数据列表</title>
<%@include file="common/include.jsp"%>
</head>
<body>
	<div class="container">
		<div class="row">
			<div class="col-lg-12">
				<br />
				<div class="panel panel-default">
					<div class="panel-body">
						<form class="form-inline" role="form" action="${ctx}/search"
							method="post">
							<div class="form-group">
								<label class="sr-only" for="systemName">系统名称</label> <input
									type="text" class="form-control" id="systemName"
									name="systemName" value="${systemName}" placeholder="系统名称">
							</div>
							<div class="form-group">
								<label class="sr-only" for="content">日志级别</label> <input
									type="text" class="form-control" id="logLevel" name="logLevel"
									value="${logLevel}" placeholder="日志级别">
							</div>
							<div class="form-group">
								<label class="sr-only" for="content">日志内容</label> <input
									type="text" class="form-control" id="logContent"
									name="logContent" value="${logContent}" placeholder="日志内容">
							</div>
							<button type="submit" class="btn btn-default">查询</button>
							<button type="reset" class="btn btn-default">重置</button>
							<button type="button" onclick="preSave()" class="btn btn-default">添加</button>
						</form>
					</div>
					<table class="table table-bordered">
						<thead>
							<tr>
								<th>ID</th>
								<th>系统名称</th>
								<th>JAVA路径</th>
								<th>日志级别</th>
								<th>日志内容</th>
								<th>记录时间</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach var="stoLog" items="${stoLogList}">
								<tr>
									<td>${stoLog.id}</td>
									<td>${stoLog.systemName}</td>
									<td>${stoLog.javaPath}</td>
									<td>${stoLog.logLevel}</td>
									<td>${stoLog.logContent}</td>
									<td><fmt:formatDate value="${stoLog.logTime}" type="both"
											pattern="yyyy-MM-dd HH:mm:ss.SSS" /></td>
									<td><a href="javascript:void(0);"
										onclick="preSave('${stoLog.id}')" title="编辑"> <i
											class="glyphicon glyphicon-edit"></i>
									</a> <a href="javascript:void(0);" onclick="del('${stoLog.id}')"
										title="删除"> <i class="glyphicon glyphicon-remove"></i>
									</a></td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
	<script>
		function preSave(id) {
			if (id == undefined || id == null || id == '') {
				window.location.href = '${ctx}/preSave';
			} else {
				window.location.href = '${ctx}/preSave?id=' + id;
			}
		}

		function del(id) {
			$.ajax({
				type : 'POST',
				url : '${ctx}/delete',
				data : {
					id : id
				},
				dataType : 'json',
				success : function(data) {
					alert(data.msg);
					if (data.success) {
						setTimeout('toIndex()', 100);
					}
				},
				error : function() {
					alert("出错了,请重试!");
				}
			});
		}
	</script>
</body>
</html>
